package com.me.screen;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.Stage;

public class BaseScreen extends Group implements Screen {
	public OrthographicCamera camera;
	protected SpriteBatch sb;
	public static Stage stage;
	
	@Override
	public void show() {
		sb = new SpriteBatch();
		stage = new Stage(1280, 720, false);
		Gdx.input.setInputProcessor(stage);
		camera = (OrthographicCamera) stage.getCamera();
	}
	
	@Override
	public void render(float arg0) {
		Gdx.gl.glClearColor(0.5f, 0.6f, 0.5f, 1);
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		if (sb != null)
			sb.setProjectionMatrix(camera.combined);
		if (camera != null)
			camera.update();
		if (stage != null){
			stage.act(arg0);
			stage.draw();
		}
	}
	
	@Override
	public void hide() {
		
	}

	@Override
	public void pause() {
		
	}

	@Override
	public void resize(int width, int height) {
		width = 1280 * width / height;
		height = 720;
		stage.setViewport(width, height, false);
	}

	@Override
	public void resume() {
		
	}
	
	@Override
	public void dispose() {
		sb.dispose();
		stage.draw();
	}
}
